import 'package:concierge/generated/assets.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:video_player/video_player.dart';

import 'logic.dart';

class SplashPage extends StatelessWidget {
  const SplashPage({super.key});

  @override
  Widget build(BuildContext context) {
    final logic = Get.find<SplashLogic>();
    final state = logic.state;
    return Stack(
      children: [
        Image.asset(Assets.launcherBackground, fit: BoxFit.fill),
        Obx(() {
          if (state.controller.value == null || !state.isInitialized.value) {
            return Center(child: CircularProgressIndicator());
          }
          return Center(
            child: AspectRatio(
              aspectRatio: state.controller.value!.value.aspectRatio,
              child: VideoPlayer(state.controller.value!),
            ),
          );
        }),
      ],
    );
  }
}
